#region Using Statements
using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using FarseerGames.FarseerPhysicsDemos.Demos.Demo1;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo2;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo3;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo4;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo5;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo6;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo7;
using FarseerGames.FarseerPhysicsDemos.Demos.Demo8;
#endregion

namespace FarseerGames.FarseerPhysicsDemos.ScreenSystem
{
    /// <summary>
    /// The main menu screen is the first thing displayed when the game starts up.
    /// </summary>
    class MainMenuScreen : MenuScreen
    {
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
        {
            MenuEntries.Add("Demo1: A Single Body");
            MenuEntries.Add("Demo2: Two Bodies With Geom");
            MenuEntries.Add("Demo3: Static Bodies And Offset Geometries");
            MenuEntries.Add("Demo4: Stacked Bodies");
            MenuEntries.Add("Demo5: Collision Categories");
            MenuEntries.Add("Demo6: Linear and Angular Spring Controllers");
            MenuEntries.Add("Demo7: Dynamic Angle Joints");
            MenuEntries.Add("Demo8: Broadphase Collision Stress Test");
            MenuEntries.Add("Exit");
            LeftBorder = 100;
        }

        /// <summary>
        /// Responds to user menu selections.
        /// </summary>
        protected override void OnSelectEntry(int entryIndex)
        {
            switch (entryIndex)
            {
                case 0:
                         ScreenManager.AddScreen(new Demo1Screen());
                    break;

                case 1:
                    ScreenManager.AddScreen(new Demo2Screen());
                    break;

                case 2:
                    ScreenManager.AddScreen(new Demo3Screen());
                    break;

                case 3:
                    ScreenManager.AddScreen(new Demo4Screen());
                    break;

                case 4:
                    ScreenManager.AddScreen(new Demo5Screen());
                    break;
                case 5:
                    ScreenManager.AddScreen(new Demo6Screen());
                    break;
                case 6:
                    ScreenManager.AddScreen(new Demo7Screen());
                    break;
                case 7:
                    ScreenManager.AddScreen(new Demo8Screen());
                    break;
                case 8: 
                    // Exit the sample.
                    OnCancel();
                    break;
            }
        }


        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit the sample.
        /// </summary>
        protected override void OnCancel()
        {
            ScreenManager.Game.Exit();
        }


        /// <summary>
        /// Event handler for when the user selects ok on the "are you sure
        /// you want to exit" message box.
        /// </summary>
        void ExitMessageBoxAccepted(object sender, EventArgs e)
        {
            ScreenManager.Game.Exit();
        }


        /// <summary>
        /// Loading screen callback for activating the gameplay screen.
        /// </summary>
        void LoadGameplayScreen(object sender, EventArgs e)
        {
            //ScreenManager.AddScreen(new GameplayScreen());
        }

        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime) {
            ScreenManager.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend);
            ScreenManager.SpriteBatch.DrawString(ScreenManager.DiagnosticSpriteFont, "*toggle between debug and normal view using either F1 on the keyboard or 'Y' on the controller", new Vector2(100, ScreenManager.ScreenHeight - 116), Color.Black);            
#if (!XBOX)
            ScreenManager.SpriteBatch.DrawString(ScreenManager.DiagnosticSpriteFont, "**keyboard users, use arrows and enter to navigate menus", new Vector2(100, ScreenManager.ScreenHeight - 100), Color.Black);
#endif
            base.Draw(gameTime);
            ScreenManager.SpriteBatch.End();
        }
    }
}
